package com.example.tests;

import static org.hamcrest.Matchers.equalTo;
import static org.junit.Assert.assertThat;

import org.testng.annotations.Test;

import com.example.fw.Contacts;

public class ContactCreationTests extends TestBase {
	
	@Test (dataProvider = "randomContacts", dataProviderClass = ContactDataGenerator.class)
	public void testValidContactCanBeCreated(ContactObject validContact) throws Exception {
		Contacts oldList = app.getContactHelper().getContacts();
		//action
		app.getContactHelper().createContact(validContact);
		//verification
		Contacts newList = app.getContactHelper().getContacts();
		assertThat(newList, equalTo(oldList.withAdded(validContact)));
	}
	
	@Test
	public void testEmptyContactCanBeCreated() throws Exception {
		ContactObject emptyDataContact = new ContactObject()
			.setFirstName("")
			.setLastName("")
			.setMainAddress("")
			.setTelephoneHome("")
			.setTelephoneMobile("")
			.setTelephoneWork("")
			.setMainEmail("")
			.setAlternativeEmail("")
			.setBirthDay("-")
			.setBirthMonth("-")
			.setBirthYear("")
			.setChooseGroup("[none]")
			.setAlternativeAddress("")
			.setAlternativeTelephoneHome("");
		Contacts oldList = app.getContactHelper().getContacts();
		//action
		app.getContactHelper().createContact(emptyDataContact);
		//verification
		Contacts newList = app.getContactHelper().getContacts();
		assertThat(newList, equalTo(oldList.withAdded(emptyDataContact)));
	}
	
}
